jQuery(document).ready(function($) {

   /* password form */
   $("#settingpasswordform").validate({
      rules: {
         newpassword_verify: {
            required: true,
            equalTo: "#newpassword"
         }
      },
      messages: {
         newpassword_verify: {
            equalTo: "两个新密码不统一"
         }
      },

      submitHandler: function(form) {
         $(form).ajaxSubmit({
           dataType: "json",
           beforeSubmit: function(data, form, options) {
               if(!showLoading(form))
                  return false;
               $(".server", form).hide();
            },
            success: function(data) {
              try {
                 var retmsg = data;
                 if(retmsg.error) { $(".server", form).jobUtil('showError', retmsg.error); }
                 else if(retmsg.success) {
                     $(".server", form).jobUtil('showSuccess', retmsg.success, function(){
                        $(".server", form).fadeOut(3000);
                     });
                 }
              } catch(e) {
                 return false;
              }
            }
        });
      }
  });

   $("#settingpasswordform #newpassword").blur(function() {
      if($(this).val().length <= 0)
         return;

      if(!$(this).jobUtil("strengthCheck"))
         $(this).nextAll(".label-warning").fadeIn();
      else
         $(this).nextAll(".label-warning").fadeOut();
   })

});
